package cn.shuangliang.contract.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 代表一页数据
 * @author oldliu
 * @since 1.0
 */
public class Page<T> implements Serializable {
    public static final int PAGE_SIZE=20;//默认页大小
    //本页数据
    private List<T> data=new ArrayList<>(0);
    private int page;//当前页
    private int count;//总条数
    private int limit=PAGE_SIZE;//页大小
    private int code=0;//是否成功的状态，0是成功
    private String msg;//信息提示
    public Page(){
    }
    public Page(List<T> data, int count, int limit) {
        this.data = data;
        this.count = count;
        this.limit = limit;
    }
    public Page(List<T> data, int page, int count, int limit) {
        this.data = data;
        this.page = page;
        this.count = count;
        this.limit = limit;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }
    public int getTotalPages(){
        return this.count/this.limit+(this.count%this.limit==0?0:1);
    }
}
